<%--  This file is part of LitSearch.

    LitSearch is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    LitSearch is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with LitSearch; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA --%>

<%------------------------------------------------------------------- benötigte JavaBeans --%>
<jsp:useBean id="languageObj" class="de.fhbrs.litsearch.LanguageBean" scope="session" />
<jsp:useBean id="userObj" class="de.fhbrs.litsearch.UserBean" scope="session" />
<jsp:useBean id="settingsObj" class="de.fhbrs.litsearch.SettingsBean" scope="request" />

<%------------------------------------------ Weitergabe des Language-Objekts an die Beans --%>
<% 
  userObj.setLanguage(languageObj);
%>

<%------------------------------------------------- Ermittlung der berechtigten Benutzer --%>
<% if (!userObj.isLoggedIn() || !settingsObj.isInIpRange(request.getRemoteAddr())) { %>
    <jsp:forward page="index.jsp?content=search&amp;extsearch=no" />
<% } %>

<%---------------------------------- Verarbeitung der Formulardaten (changePasswordForm) --%>
<jsp:setProperty name="userObj" property="oldPassword" />
<jsp:setProperty name="userObj" property="password" />
<jsp:setProperty name="userObj" property="passRepeated" />

<h2 class="admin"><%= languageObj.getTextFor("admin.changePass") %></h2>

<%
  if (request.getParameter("changePassword") != null) userObj.updatePassword();
  else userObj.reset();

  if (request.getParameter("changePassword") != null) {
    out.println(userObj.getError());
    out.println(userObj.getMessage()+"<br />");
  }
  
  if (userObj.getMessage().length() > 0) {
    userObj.logout();
  }
  else {
%>

<form name="changePasswordForm" method="post" action="index.jsp?content=changepass">
<table id="admin">
  <tr>
    <td><%= languageObj.getTextFor("changepass.oldPassword") %>:</td>
    <td><input type="password" maxlength="30" name="oldPassword" alt="<%= languageObj.getTextFor("changepass.oldPassword") %>" /></td>
  </tr>
  <tr>
    <td><%= languageObj.getTextFor("changepass.newPassword") %>:</td>
    <td><input type="password" maxlength="30" name="password" alt="<%= languageObj.getTextFor("changepass.newPassword") %>" /></td>
  </tr>
  <tr>
    <td><%= languageObj.getTextFor("changepass.newPasswordRepeated") %>:</td>
    <td><input type="password" maxlength="30" name="passRepeated" alt="<%= languageObj.getTextFor("changepass.newPasswordRepeated") %>" /></td>
  </tr>
  <tr>
    <td></td>
    <td><input type="submit" name="changePassword" alt="<%= languageObj.getTextFor("changepass.savePassword") %>" value="<%= languageObj.getTextFor("changepass.savePassword") %>" /></td>
  </tr>
</table>
</form>

<% } %>
